package com.firebird.app.kotlin.stock.utils

import android.app.Activity
import android.app.AlertDialog
import android.content.Intent
import android.view.View
import com.firebird.app.kotlin.stock.R
import com.firebird.app.kotlin.stock.ui.login.LoginActivity


object ShowDialogUtils {
    fun restLoginDialog(activity: Activity) {
        val builder = AlertDialog.Builder(activity).create()
        val layoutInflater = activity.layoutInflater
        val view: View = layoutInflater.inflate(R.layout.dialog_timeout, null)
        builder.setView(view)
        builder.setCancelable(false)
        builder.show()
        SharedPreferencesUtil.getInstance(activity)!!.putSP("token", "")
        SharedPreferencesUtil.getInstance(activity)!!.putSP("debtorid", "")
        view.findViewById<View>(R.id.tv_sure).setOnClickListener {
            val intent = Intent(activity, LoginActivity::class.java)
            intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
            activity.startActivity(intent)
            activity.finish()
            builder.dismiss()
        }
    }
}